package com.hbnu.system.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hbnu.system.config.BaseException;
import com.hbnu.system.mapper.WorkpressMapper;
import com.hbnu.system.model.entity.Work_press;
import com.hbnu.system.service.IWorkPressSerivce;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Service
public class WorkPressServiceImpl extends ServiceImpl<WorkpressMapper, Work_press> implements IWorkPressSerivce {
    @Override
    public boolean addWorkPress(Work_press work_press) {
        return false;
    }

    @Override
    public boolean deleteWorkPress(String ID) {
        return false;
    }

    @Override
    public boolean updateWorkPress(Work_press work_press) {
        return false;
    }

    @Override
    public Work_press checkOneWorkPress(String ID) {
        Work_press one = super.getOne(Wrappers.lambdaQuery(Work_press.class)
                .eq(Work_press::getWorkPressID, ID));
        if(Objects.isNull(one)){
            throw new BaseException("该出版社不存在或ID有误!");
        }
        return  one;
    }

    @Override
    public List<Work_press> checkWrokPresses() {
        List<Work_press> work_presses = baseMapper.selectList(Wrappers.lambdaQuery(Work_press.class)
        );
        return work_presses;
    }
}
